package com.dyp.cachedemo;

import com.dyp.cachedemo.service.PersonService;
import com.dyp.cachedemo.service.dto.PersonDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;

@SpringBootApplication
@EnableCaching
public class CacheDemoApplication implements CommandLineRunner {


	@Autowired
	PersonService personService;

	public static void main(String[] args) {
		SpringApplication.run(CacheDemoApplication.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		PersonDTO person = personService.getPersonById("id");
		System.out.println(person.toString());
		System.out.println("=====================end===================");
		person = personService.getPersonById("id");
		System.out.println(person.toString());
		System.out.println("=====================end===================");
		personService.deletePerson("id");
		System.out.println("=====================end===================");
		person = personService.getPersonById("id");
		System.out.println(person.toString());
		System.out.println("=====================end===================");
		PersonDTO updatePerson = new PersonDTO();
		updatePerson.setId("id");
		person = personService.updatePerson(updatePerson);
		System.out.println("=====================end===================");
		person = personService.getPersonById("id");
		System.out.println(person.toString());
		System.out.println("=====================end===================");
	}
}
